Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GazeLockControl Trait to extend control functionality #28

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jackbayliss
Copy link

@jackbayliss jackbayliss commented Sep 28, 2024

This adds a new Trait called GazeLockControl

The idea is it extends the functionality of the plugin so you easily see if the current user is the controlling user and define what is hidden in your pages etc based on that logic.

This isn't forced etc, so is up to the user to implement if they want the logic.

For example, take the below, I have an Edit Customer page, where I only want users controlling the page to have the ability to save / delete.

This is something I also saw via #26 so thought I'd give it a whirl at implementing.

Below is an example of how it works in this use case - for example an Edit page:

class EditCustomer extends EditRecord
{
    use GazeLockControl;

    protected static string $resource = CustomerResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make()->hidden(!$this->hasGazeControl()),
        ];
    }

    protected function getFormActions(): array
    {
        return [
            Actions\Action::make('Save')->action('save')->hidden(!$this->hasGazeControl()),
        ];
    }
}

Here's a Loom of how it works also:
https://www.loom.com/share/f8c66721ff934ea8bba86be8d39af7bc?sid=21cb0f9c-8eb1-47ba-a18b-b6ffe446939c

Let me know if there's any adjustments needed 👍🏻

prevent saving if not in control
change method, add cache timeout.
ensure if it has no viewers, its true-- as the only viewer is the current user?
add return types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant